home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gs.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.2 KB  |  82 lines

  1. /* Copyright (C) 1989, 1995, 1996, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gs.c,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  20. /* 'main' program for Ghostscript */
  21. #include "ghost.h"
  22. #include "imain.h"
  23. #include "imainarg.h"
  24. #include "iminst.h"
  25.  
  26. /* Define an optional array of strings for testing. */
  27. /*#define RUN_STRINGS */
  28. #ifdef RUN_STRINGS
  29. private const char *run_strings[] =
  30. {
  31.     "2 vmreclaim /SAVE save def 2 vmreclaim",
  32.     "(saved\n) print flush",
  33.     "SAVE restore (restored\n) print flush 2 vmreclaim",
  34.     "(done\n) print flush quit",
  35.     0
  36. };
  37.  
  38. #endif
  39.  
  40. int
  41. main(int argc, char *argv[])
  42. {
  43.     gs_main_instance *minst = gs_main_instance_default();
  44.     int code = gs_main_init_with_args(minst, argc, argv);
  45.  
  46.     if (code < 0) {
  47.     gs_exit_with_code(255, code);
  48.     /* NOTREACHED */
  49.     }
  50. #ifdef RUN_STRINGS
  51.     {                /* Run a list of strings (for testing). */
  52.     const char **pstr = run_strings;
  53.  
  54.     for (; *pstr; ++pstr) {
  55.         int exit_code;
  56.         ref error_object;
  57.         int code;
  58.  
  59.         fprintf(stdout, "{%s} =>\n", *pstr);
  60.         fflush(stdout);
  61.         code = gs_main_run_string(minst, *pstr, 0,
  62.                       &exit_code, &error_object);
  63.         zflush(osp);
  64.         fprintf(stdout, " => code = %d\n", code);
  65.         fflush(stdout);
  66.         if (code < 0) {
  67.         gs_exit(1);
  68.         /* NOTREACHED */
  69.         return 1;    /* pacify compilers */
  70.         }
  71.     }
  72.     }
  73. #endif
  74.  
  75.     if (minst->run_start)
  76.     gs_main_run_start(minst);
  77.  
  78.     gs_exit(0);            /* exit */
  79.     /* NOTREACHED */
  80.     return 0;            /* pacify compilers */
  81. }
  82.